//////////////////////////////////////////////////////////////////////////////
//
// File:  bot.h
// 
// Description: 
//   This file contains a bot class object that controls and utilizes all the
//   bot commands and text outputs.  It receives its data from bnet from
//   conGuy, and receives/sends it's input and output to the server.
//   

#ifndef BOT_H
#define BOT_H

#include <string>
#include <qwidget.h>
#include <qtimer.h>

using namespace std;

#include "src/conGuy/types.h"
#include "src/conGuy/conGuy.h"
#include "src/event/BnetEvent.h"
#include "src/gui/ChatDialog.h"



class bot : public QWidget {
  Q_OBJECT
 public:
  bot();
  ~bot();
  bool exec();
  bool findConGuyConfig();
  void setConGuyConfig( const string& conGuyConfigFilename );
 signals:
  void appendChat(QString, QString);
public slots:
  void sendMsg(QString);
  void exit();
  bool chat_event_handler();
  bool startTimer();  // spawns threads for chat event handlers.
 private:
  void log(string msg);      // These will emit the appendChat signal.
  void chatlog(string msg);
  void whisperlog(string msg);
  void serverlog(string msg);
  void channellog(string msg);
  void melog(string msg);

  // GUI stuff.
  ChatDialog chatDialog;
  bool done_;

  string unique_username;
  string curr_channel;
  BnetEvent new_event;

  QTimer *checkForEventTimer;

  conGuy *bnet;    // bnet points to one of the following 4 conGuys

  // Configured options from config file.
  string database_file;
  string admin_accnt;
  string chatlog_file_base;

  bool bot_chatlog;
  bool bot_cmds;
  bool bot_mail;
  bool bot_mailops;
  bool bot_mailall;
  bool bot_allseen;
  bool bot_seen;
  bool bot_banlist;
  bool bot_beep;
  bool bot_admin;
  bool bot_greet;
  bool bot_say;
  bool bot_say_exact;
  bool bot_smackdown;
  bool bot_mama_smackdown;
  bool bot_polls;    // polls and votes
  

  // Some functions...
//   bool open_sql_db();
  string get_timestamp();

};


struct bot_and_conGuy_t {
  bot *aBot;
  conGuy *aConGuy;
};


// Event ID's

#define EID_SHOWUSER			0x01  
#define EID_JOIN			0x02  
#define EID_LEAVE			0x03  
#define EID_WHISPER			0x04  
#define EID_TALK			0x05  
#define EID_BROADCAST			0x06  
#define EID_CHANNEL			0x07  
#define EID_USERFLAGS			0x09  
#define EID_WHISPERSENT			0x0A  
#define EID_CHANNELFULL			0x0D  
#define EID_CHANNELDOESNOTEXIST		0x0E  
#define EID_CHANNELRESTRICTED		0x0F  
#define EID_INFO			0x12  
#define EID_ERROR			0x13  
#define EID_EMOTE			0x17  



// Channel flags.

#define CHANNEL_PUBLIC			0x01  
#define CHANNEL_MODERATED		0x02  
#define CHANNEL_RESTRICTED		0x04  
#define CHANNEL_SILENT			0x08  
#define CHANNEL_SYSTEM			0x10  
#define CHANNEL_PRODUCTSPECIFIC		0x20 
#define CHANNEL_GLOBAL			0x1000  



// User flags.

#define USER_BLIZZREP			0x01  
#define USER_CHANNELOP			0x02  
#define USER_SPEAKER			0x04  
#define USER_ADMIN			0x08  
#define USER_NOUDP			0x10  
#define USER_SQUELCHED			0x20  
#define USER_GUEST			0x40  
#define USER_BEEPENABLED		0x100  
#define USER_PGLPLAYER			0x200  
#define USER_PGLOFFICIAL		0x400  
#define USER_KBKPLAYER			0x800  
#define USER_KBKOFFICIAL		0x1000  
#define USER_JAILED			0x100000  
#define USER_GFPLAYER			0x200000  





// Event ID's.

#define EID_SHOWUSER			0x01  
#define EID_JOIN			0x02  
#define EID_LEAVE			0x03  
#define EID_WHISPER			0x04  
#define EID_TALK			0x05  
#define EID_BROADCAST			0x06  
#define EID_CHANNEL			0x07  
#define EID_USERFLAGS			0x09  
#define EID_WHISPERSENT			0x0A  
#define EID_CHANNELFULL			0x0D  
#define EID_CHANNELDOESNOTEXIST		0x0E  
#define EID_CHANNELRESTRICTED		0x0F  
#define EID_INFO			0x12  
#define EID_ERROR			0x13  
#define EID_EMOTE			0x17  


#endif
